package Presenter;

import InterFaceIModel.ILoaiThuChi;
import InterFaceIModel.LoaiThuChiModel;
import View.ILoaiThuChiDetailView;
import View.ILoaiThuChiView;


public class LoaiThuChiPresenter {

	ILoaiThuChiDetailView iView;
	public LoaiThuChiPresenter(ILoaiThuChiDetailView iView)
	{
		this.iView=iView;
	}
	public long insert()
	{
		if (iView.getTenLoai().equals("")) {
			iView.setMessage("Ban Phai nhap Ten Loai thu chi!");
			return 0;
		}
		ILoaiThuChi loaiThuChi=new LoaiThuChiModel();
		loaiThuChi.setGhichu(iView.getGhichu());
		loaiThuChi.setIsThucThi(iView.getIsthuchi());
		loaiThuChi.setTenLoai(iView.getTenLoai());
		long x=loaiThuChi.insert(loaiThuChi, iView.getContext());
		if (x>0) {
			return x;
		}
		return 0;
	}
	ILoaiThuChiView view;
	public LoaiThuChiPresenter(ILoaiThuChiView view)
	{
		this.view=view;
	}
	public void LoadAll()
	{
		ILoaiThuChi loaiThuChi=new LoaiThuChiModel();
		view.setListLoaiThuChi(loaiThuChi.getAll(view.getIsThuChi(), view.getContext()));
	}
}
